/**
 * 神州信息(2012)
 */
package com.reportgear.report.model.calculator;

import java.util.Iterator;

import net.abbp.report.model.Cell;
import net.abbp.report.model.ReportModel;

/**
 * 子报表计算
 * 
 * @version 1.0
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since ABBP 1.0
 * 
 *        <pre>
 * 历史：
 *      建立: 2012-7-24 lexloo
 * </pre>
 */
public class SubReportCalculator implements Calculator {

    @Override
    public ReportModel calculate(ReportModel model, CalcParameter parameter) {
        if (logger.isDebugEnabled()) {
            logger.debug("计算模型：子报表");
        }

        ReportModel calcModel = model;

        Iterator<Cell> cells = calcModel.getCellsIteratorByCellElementClass(ReportModel.class);
        for (Iterator<Cell> i = cells; i.hasNext();) {
            Cell cell = i.next();

            ReportModel m = (ReportModel) cell.getValue();

            // 计算简历
            m = new ResumeCalculator().calculate(m, parameter);
        }

        return calcModel;
    }
}
